package bTree.LeetCode;

public class 无法吃午餐的学生数量 {
    public int countStudents(int[] students, int[] sandwiches) {
        int yuan=0,fang=0;
        for (int student : students) {
            if (student==0){
                yuan++;
            }else {
                fang++;
            }
        }
        for (int sandwich : sandwiches) {
            if (sandwich==0){
                if (yuan==0){
                    return fang;
                }else {
                    yuan--;
                }
            }else {
                if (fang==0){
                    return yuan;
                }else {
                    fang--;
                }
            }
        }
        return 0;
    }
}